/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Campeonato;

import Instancia.Objetos;
import Pessoa.Jogador;
import Time.Time;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrador
 */
public class Torneio {

    ArrayList<Time> times;
    private Time meu;
    private Time adv;
    Objetos o;

    public Torneio(Objetos o, Time time) {
        this.o = o;
        times = new ArrayList<>();
        if (time != o.getBotafogo()) {
            times.add(o.getBotafogo());
        }
        if (time != o.getFla()) {
            times.add(o.getFla());
        }

        if (time != o.getFlu()) {
            times.add(o.getFlu());
        }
        if (time != o.getGremio()) {
            times.add(o.getGremio());
        }
        if (time != o.getInter()) {
            times.add(o.getInter());
        }
        if (time != o.getSantos()) {
            times.add(o.getSantos());
        }
        if (time != o.getSaoPaulo()) {
            times.add(o.getSaoPaulo());
        }
        if (time != o.getVasco()) {
            times.add(o.getVasco());
        }
        meu = time;

    }

    public void rodada1() {
        Embate e1 = new Embate(times.get(0), times.get(1));
        e1.vitoria().setPontos(3);
        Embate e2 = new Embate(times.get(3), times.get(2));
        e2.vitoria().setPontos(3);
        Embate e3 = new Embate(times.get(4), times.get(5));
        e3.vitoria().setPontos(3);
        Embate e4 = new Embate(getMeu(),adv=times.get(6));

    }
    public void rodada2() {
        Embate e5 = new Embate(times.get(0), times.get(2));
        e5.vitoria().setPontos(3);
        Embate e6 = new Embate(times.get(1), times.get(3));
        e6.vitoria().setPontos(3);
        Embate e7 = new Embate(times.get(4), times.get(6));
        e7.vitoria().setPontos(3);
        Embate e8 = new Embate( getMeu(),adv=times.get(5));
    }

    public void rodada3() {

        Embate e9 = new Embate(times.get(2), times.get(1));
        e9.vitoria().setPontos(3);
        Embate e10 = new Embate(times.get(3), times.get(0));
        e10.vitoria().setPontos(3);
        Embate e11 = new Embate(times.get(6), times.get(5));
        e11.vitoria().setPontos(3);
        Embate e12 = new Embate(getMeu(),adv= times.get(4));
        
    }

    public void rodada4() {

        Embate e13 = new Embate(times.get(4), times.get(0));
        e13.vitoria().setPontos(3);
        Embate e14 = new Embate(times.get(1), times.get(5));
        e14.vitoria().setPontos(3);
        Embate e15 = new Embate(times.get(2), times.get(6));
        e15.vitoria().setPontos(3);
        Embate e16 = new Embate(getMeu(), adv=times.get(3));
        
    }

    public void rodada5() {

        Embate e17 = new Embate(getMeu(),adv= times.get(2));
        Embate e18 = new Embate(times.get(6), times.get(3));
        e18.vitoria().setPontos(3);
        Embate e19 = new Embate(times.get(1), times.get(4));
        e19.vitoria().setPontos(3);

        Embate e20 = new Embate(times.get(0), times.get(5));
        e20.vitoria().setPontos(3);
    }

    public void rodada6() {

        Embate e21 = new Embate( getMeu(),adv=times.get(0));
        Embate e22 = new Embate(times.get(6), times.get(1));
        e22.vitoria().setPontos(3);
        Embate e23 = new Embate(times.get(2), times.get(5));
        e23.vitoria().setPontos(3);

        Embate e24 = new Embate(times.get(4), times.get(3));
        e24.vitoria().setPontos(3);
    }

    public void rodada7() {

        Embate e25 = new Embate(times.get(6), times.get(0));
        e25.vitoria().setPontos(3);
        Embate e26 = new Embate(getMeu(), adv=times.get(1));
        
        Embate e27 = new Embate(times.get(2), times.get(4));
        e27.vitoria().setPontos(3);
        Embate e28 = new Embate(times.get(5), times.get(3));
        e28.vitoria().setPontos(3);
    }
    public void geraCampeao(){
        Time camp = null;
        for (int i = 0; i < 7; i++) {
            if (times.get(i).getPontos()>meu.getPontos()) {
                
            camp = times.get(i);
            }else
                camp=meu;
            
            if (times.get(i).getPontos()>camp.getPontos()) {
                camp=times.get(i);
            }
        }
        JOptionPane.showMessageDialog(null, "O grande vencedor foi o "+camp.getNome());
        
    }

    /**
     * @return the meu
     */
    public Time getMeu() {
        return meu;
    }

    /**
     * @param meu the meu to set
     */
    public void setMeu(Time meu) {
        this.meu = meu;
    }

    /**
     * @return the adv
     */
    public Time getAdv() {
        return adv;
    }

    /**
     * @param adv the adv to set
     */
    public void setAdv(Time adv) {
        this.adv = adv;
    }
}
